﻿namespace LogManager.Core.Helpers
{
    using LogManager.Core.Models;
    using NSubstitute;
    using NUnit.Framework;

    public class TestModelsExtensions
    {
        [Test]
        public void ModelsExtensions_GetSourceCredentials_Ilocation_GoodCredentials()
        {
            var plateform = Substitute.For<IPlateform>();
            plateform.Domain = "domain1";
            plateform.Login = "Login1";
            plateform.Password = "Password1";

            var location = Substitute.For<ILocation>();
            location.ParentServer.ParentPlateform.Returns(plateform);

            var cred = location.GetSourceCredentials();
            Assert.AreEqual("domain1", cred.Domain);
            Assert.AreEqual("Login1", cred.UserName);
            Assert.AreEqual("Password1", cred.Password);
        }

        [Test]
        public void ModelsExtensions_GetDestinationCredentials_Ilocation_GoodCredentials()
        {
            var warehouse = Substitute.For<IWarehouse>();
            warehouse.Domain = "domain1";
            warehouse.Login = "Login1";
            warehouse.Password = "Password1";

            var location = Substitute.For<ILocation>();
            location.ParentServer.ParentPlateform.ParentWarehouse.Returns(warehouse);

            var cred = location.GetDestinationCredentials();
            Assert.AreEqual("domain1", cred.Domain);
            Assert.AreEqual("Login1", cred.UserName);
            Assert.AreEqual("Password1", cred.Password);
        }
    }
}
